package com.eddie.singleton.type8;

/**
 * @author Eddie
 * @date 2022/4/29 9:18
 */
public class SingletonTest08 {

    public static void main(String[] args) {
        Singleton instance = Singleton.INSTANCE;
        Singleton instance2 = Singleton.INSTANCE;
        System.out.println(instance == instance2);
        instance.sayOk();

    }

}

/**
 * 使用枚举创建单例，推荐
 */
enum Singleton {
    INSTANCE;

    public void sayOk() {
        System.out.println("OK");
    }
}
